/**
 * @type {import('webpack').Configuration}
 * We need to preserve this JavaScript configuration because the cypress/plugins/index.js need it.
 * And Cypress plugin is accept only JavaScript files.
 */
module.exports = {
  resolve: {
    extensions: ['.ts', '.tsx', '.js'],
  },

  module: {
    rules: [
      {
        test: /\.m?js?$/,
        resolve: {
          fullySpecified: false,
        },
      },
      {
        test: /\.tsx?$/,
        use: [
          {
            loader: '@swc-node/loader',
            options: {
              compilerOptions: {
                target: 'esnext',
                module: 'esnext',
                jsx: 'react-jsx',
                experimentalDecorators: true,
                esModuleInterop: true,
              },
            },
          },
        ],
        exclude: /node_modules/,
      },
    ],
  },
}
